<%@ Page Language="C#" Theme="Defaultsys" AutoEventWireup="true" CodeFile="AssignCalls.aspx.cs"
    Inherits="AssignCalls" Title="Rapport Plan System - Assign calls" MasterPageFile="~/MasterPage.master" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">

    <script type="text/javascript" language="javascript">
    var checkflag = "false";

    function CheckAll(id)
    {
	    if (checkflag == "false") 
	    {
		    var el = document.getElementById(id);
		    for (var i = 0; i < el.elements.length; i++) 
		    {
		      el.elements[i].checked = "true";
		    }
		    checkflag = "true";
		    return "Uncheck All"; 		
	    }
	    else
	    {
		    var el = document.getElementById(id);
		    for (var i = 0; i < el.elements.length; i++) 
		    {
		      el.elements[i].checked = false;
		    }
		    checkflag = "false";
		    return "Check All"; 				
	    }
	    
    }
    </script>

    <table class="contTable"  border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td style="width: 264px">
                User:</td>
            <td>
                <asp:Label ID="lblUser" runat="server" Text="">User 1</asp:Label></td>
        </tr>
        <tr>
            <td style="width: 264px">
                Maximum number of calls:</td>
            <td>
                <asp:Label ID="lblMaxNumberCalls" runat="server" Text="">7</asp:Label></td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:GridView ID="grdCalls" SkinID="gvGrid" runat="server" AutoGenerateColumns="false" DataKeyNames="CallId"
                    AllowPaging="true" Width="100%" OnPageIndexChanging="grdCalls_PageIndexChanging">
                    <Columns>
                        <asp:TemplateField HeaderText="ID" 
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="3%">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                        <asp:BoundField HeaderText="Contact" DataField="Name" SortExpression="Name" 
                        HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                        <asp:BoundField HeaderText="Phone" DataField="Phone" SortExpression="Phone" 
                        HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                        <asp:BoundField HeaderText="Mobile phone" DataField="MobilePhone" SortExpression="MobilePhone"
                        HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
                        
                        <asp:BoundField HeaderText="From" DataField="From" SortExpression="From" DataFormatString="{0:MM/dd/yyyy}"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HtmlEncode="false" />
                        <asp:BoundField HeaderText="To" DataField="DaysTo" SortExpression="DaysTo" DataFormatString="{0:MM/dd/yyyy}"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HtmlEncode="false" />
                            
                        <asp:BoundField HeaderText="Assigned caller" DataField="UserName" SortExpression="UserName" 
                            HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                        <asp:BoundField HeaderText="Call reason" DataField="CallReason" SortExpression="CallReason"
                            HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left" NullDisplayText="-" />
                        <asp:TemplateField HeaderText="Assign call" 
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="ckAssignCall" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="CallId" Visible="false">
                            <ItemTemplate>
                                <asp:HiddenField ID="txtCallId" runat="server" Value='<%# Eval("CallId") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:Button ID="btnCheckAll" runat="server" Text="Check all" />
                <asp:Button ID="btnAssignCalls" runat="server" Text="Assign calls" OnClick="AssignSelectedCalls" />
                <asp:Button ID="btnClose" runat="server" Text="Cancel" OnClick="btnClose_Click" />
                <br />
                <asp:Label ID="lblAssignedMessage" runat="server" ForeColor="#FF8000" Text="The calls have been assigned"
                    Visible="False"></asp:Label></td>
        </tr>
    </table>
</asp:Content>
